/* ******* Red Rotations ******** */

void r1(struct aCube * cube) {
	r1c( cube );
	r1e( cube );
}

void r2(struct aCube * cube) {
	r2c( cube );
	r2e( cube );
}

void r3(struct aCube * cube) {
	r3c( cube );
	r3e( cube );
}

void r1c(struct aCube * cube) {

	short temp = cube[C3].r;
	cube[C3].r = cube[C7].r;
	cube[C7].r = cube[C5].r;
	cube[C5].r = cube[C4].r;
	cube[C4].r = temp;

	temp = cube[C3].w;
	cube[C3].w = cube[C7].g;
	cube[C7].g = cube[C5].y;
	cube[C5].y = cube[C4].b;
	cube[C4].b = temp;

	temp = cube[C3].g;
	cube[C3].g = cube[C7].y;
	cube[C7].y = cube[C5].b;
	cube[C5].b = cube[C4].w;
	cube[C4].w = temp;

        temp = cube[C3].pos;
        cube[C3].pos = cube[C7].pos;
        cube[C7].pos = cube[C5].pos;
        cube[C5].pos = cube[C4].pos;
        cube[C4].pos = temp;
}

void r1e(struct aCube * cube) {

	short temp = cube[E11].r;
	cube[E11].r = cube[E17].r;
	cube[E17].r = cube[E16].r;
	cube[E16].r = cube[E18].r;
	cube[E18].r = temp;

	temp = cube[E11].w;
	cube[E11].w = cube[E17].g;
	cube[E17].g = cube[E16].y;
	cube[E16].y = cube[E18].b;
	cube[E18].b = temp;

	temp = cube[E11].pos;
        cube[E11].pos = cube[E17].pos;
        cube[E17].pos = cube[E16].pos;
        cube[E16].pos = cube[E18].pos;
        cube[E18].pos = temp;
}

void r2c(struct aCube * cube) {

	short temp = cube[C3].r;
	cube[C3].r = cube[C5].r;
	cube[C5].r = temp;
	temp = cube[C4].r;
	cube[C4].r = cube[C7].r;
	cube[C7].r = temp;

	temp = cube[C3].w;
	cube[C3].w = cube[C5].y;
	cube[C5].y = temp;
	temp = cube[C3].g;
	cube[C3].g = cube[C5].b; 
	cube[C5].b = temp;

	temp = cube[C4].w;
	cube[C4].w = cube[C7].y;
	cube[C7].y = temp;
	temp = cube[C4].g;
	cube[C4].g = cube[C7].b;
	cube[C7].b = temp;

	temp = cube[C4].pos;
        cube[C4].pos = cube[C7].pos;
        cube[C7].pos = temp;
	temp = cube[C3].pos;
        cube[C3].pos = cube[C5].pos;
        cube[C5].pos = temp;
}

void r2e(struct aCube * cube) {

	short temp = cube[E11].r;
	cube[E11].r = cube[E16].r;
	cube[E16].r = temp;
	temp = cube[E17].r;
	cube[E17].r = cube[E18].r;
	cube[E18].r = temp;

	temp = cube[E11].w;
	cube[E11].w = cube[E16].y;
	cube[E16].y = temp;
	temp = cube[E17].g;
	cube[E17].g = cube[E18].b;
	cube[E18].b = temp;

        temp = cube[E11].pos;
        cube[E11].pos = cube[E16].pos;
        cube[E16].pos = temp;
        temp = cube[E17].pos;
        cube[E17].pos = cube[E18].pos;
        cube[E18].pos = temp;
}

void r3c(struct aCube * cube) {

	short temp = cube[C3].r;
	cube[C3].r = cube[C4].r;
	cube[C4].r = cube[C5].r;
	cube[C5].r = cube[C7].r;
	cube[C7].r = temp;

	temp = cube[C3].w;
	cube[C3].w = cube[C4].b;
	cube[C4].b = cube[C5].y;
	cube[C5].y = cube[C7].g;
	cube[C7].g = temp;

	temp = cube[C3].b;
	cube[C3].b = cube[C4].y;
	cube[C4].y = cube[C5].g;
	cube[C5].g = cube[C7].w;
	cube[C7].w = temp;

        temp = cube[C3].pos;
        cube[C3].pos = cube[C4].pos;
        cube[C4].pos = cube[C5].pos;
        cube[C5].pos = cube[C7].pos;
        cube[C7].pos = temp;
}

void r3e(struct aCube * cube) {

	short temp = cube[E11].r;
	cube[E11].r = cube[E18].r;
	cube[E18].r = cube[E16].r;
	cube[E16].r = cube[E17].r;
	cube[E17].r = temp;

	temp = cube[E11].w;
	cube[E11].w = cube[E18].b;
	cube[E18].b = cube[E16].y;
	cube[E16].y = cube[E17].g;
	cube[E17].g = temp;

        temp = cube[E11].pos;
        cube[E11].pos = cube[E18].pos;
        cube[E18].pos = cube[E16].pos;
        cube[E16].pos = cube[E17].pos;
        cube[E17].pos = temp;
}
